<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>文章类型的管理</title>

<script type="text/javascript">
	function refresh()
	{
		if (window.confirm('你确认需要刷新缓存吗？')) {
			window.location.href = "${pageContext.request.contextPath }/SystemRefresh.action";
			alert("刷新成功!");
		} else {

		}
	}
</script>

<script type="text/javascript"
	src="${pageContext.request.contextPath }/static/js/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/static/js/EasyUI/jquery.easyui.min.js"></script>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/static/js/EasyUI/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/static/js/EasyUI/themes/icon.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath }/static/js/EasyUI/easyui-lang-zh_CN.js"></script>
</head>
<body>
	<table id="dg">

	</table>
	<a style="color: red;">PS:笔的图标是编辑选中的文章类型 橡皮擦的图标是删除选中的文章类型 加号是添加文章类型
	<br/> 还要注意的是如果文章类型下如果还有文章关联 则不能删除
	</a>

	<script type="text/javascript">
		$('#dg')
				.datagrid(
						{
							url : "${pageContext.request.contextPath}/admin/articleType/list.do",
							columns : [ [ {
								field : 'cb',
								checkbox : true
							},

							{
								field : 'typeId',
								title : '文章类型编号',
								width : 100
							},  {
								field : 'typeName',
								title : '文章类型名',
								width : 100
							},

							] ],
							toolbar : [
									{
										iconCls : 'icon-edit',
										handler : function() {
											var selectRows = $("#dg").datagrid(
													"getSelections");
											if(selectRows.length==0)
											{
												$.messager.alert("系统提示","请选择要编辑的的行数");
											}
											else
											{
												$.messager.prompt('提示信息', '请输入你要修改的文章类型名：', function(r){
													if (r){
														$.post("${pageContext.request.contextPath}/admin/articleType/save.do",
																{
																	"typeId" : selectRows[0].typeId,
																	"typeName" : r
																},
																function(success){
																	window.location.href="${pageContext.request.contextPath}/admin/articleType/listUI.do";
																},"json"
															);
															 $.messager.alert("操作提示", "操作成功！","info");
													}
												});


											}
										}
									}, '-', {
										iconCls : 'icon-remove',
										handler : function() {
												var selectRows = $("#dg").datagrid("getSelections");
												if(selectRows.length==0)
												{
													$.messager.alert("系统提示","请选择要删除的的行数");
												}
												else
												{
													$.post("${pageContext.request.contextPath}/admin/articleType/delete.do",
														{
															"typeId" : selectRows[0].typeId,
															"typeName" : selectRows[0].typeName
														},
														function(success){
															if(success)
																{
																	window.location.href="${pageContext.request.contextPath}/admin/articleType/listUI.do";
													     		    $.messager.alert("操作提示", "操作成功！","info");
																
																}
															else
																{
																 $.messager.alert("操作提示", "操作失败！","info");
																
																}
														},"json"
													);
													
												}
										}
									} , '-', {
										iconCls : 'icon-add',
										handler : function() {
												$.messager.prompt('提示信息', '请输入你要添加的文章类型名：', function(r){
													if(r!=null)
														{
															$.post("${pageContext.request.contextPath}/admin/articleType/save.do",{
																"typeName" : r
																
															},function(success){
																window.location.href="${pageContext.request.contextPath}/admin/articleType/listUI.do";
															},"json");
													 $.messager.alert("操作提示", "操作成功！","info");
														}
													
												});
													
											}
										
										}
									 ],
							singleSelect : true,
							fitColumns : true,
							pagination : true,
							pageNumber : 1,
							pageSize : 4,
							pageList : [ 4 ],
						});
		
	</script>
</body>
</html>